home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / tdosly12.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  5.9 KB  |  239 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TDosLynx : public TApplication
  4. //    Include File:    TDosLynx.h
  5. //    Purpose:    Implement our application object.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-09-93    created
  9. //        02-09-04    Split all members to seperate files to enhance
  10. //                overlay support.
  11. #define Uses_TDeskTop
  12. #include"tdoslynx.h"
  13. #include"turlwind.h"
  14. #include"tcapture.h"
  15. #include"globals.h"
  16. #include"trace.h"
  17. #include"urltodos.h"
  18. #include<ctype.h>
  19. #include<string.h>
  20. #include<stdlib.h>
  21.  
  22. void TDosLynx::EvalOption(int i_sequence, char *cp_argument)    {
  23. //    Purpose:    Determine the implications of a command line argument
  24. //    Arguments:    i_sequence    A number corellating to the array in
  25. //                    the list the argument was on the
  26. //                    command line.
  27. //            cp_argument    The argument to evaluate.
  28. //    Return Value:   void
  29. //    Remarks/Portability/Dependencies/Restrictions:
  30. //    Revision History:
  31. //        12-13-93    created
  32.  
  33.     if(i_sequence == 0)    {
  34.         //    This is the actual command issued to execute doslynx.
  35.         //    Parse only if need be.
  36.     }
  37.     else    {
  38.         //    Here, we take care of options.
  39.  
  40.         //    If there is no leading slash, we assume a url.
  41.         if(*cp_argument != '/')    {
  42.             //    Check if this is a dos path.  If so,
  43.             //    convert it to a URL.
  44.             //    We check by attempt to recognize any possible
  45.             //    url access types, and if not, then assume a
  46.             //    dos path.
  47.             auto char urlbuff[usi_TILURLSize];
  48.             if(strncmpi("wais:", cp_argument, 5))    {
  49.             if(strncmpi("news:", cp_argument, 5))    {
  50.             if(strncmpi("ftp:", cp_argument, 4))    {
  51.             if(strncmpi("gopher:", cp_argument, 7))    {
  52.             if(strncmpi("http:", cp_argument, 5))    {
  53.             if(strncmpi("rlogin:", cp_argument, 7))    {
  54.             if(strncmpi("file:", cp_argument, 5))    {
  55.             if(strncmpi("telnet:", cp_argument, 7))    {
  56.             if(strncmpi("nntp:", cp_argument, 5))    {
  57.             if(strncmpi("mailto:", cp_argument, 7))    {
  58.                 //    assume a dos path.
  59.                 //    Put the dos path in the open local
  60.                 //    history.
  61.                 historyAdd(usi_OpenLocalHist, cp_argument);
  62.  
  63.                 //    Convert to a URL that WWW will take.
  64.                 dostourl(urlbuff, cp_argument);
  65.                 cp_argument = urlbuff;
  66.             }
  67.             }
  68.             }
  69.             }
  70.             }
  71.             }
  72.             }
  73.             }
  74.             }
  75.             }
  76.  
  77.             //    Create our new valid window.
  78.             TView *TV_new = validView((TView *)new
  79.                 TURLWindow(cp_argument));
  80.  
  81.             //    If not created, don't insert onto the desktop.
  82.             //    Assume WWW produced appropriate error message.
  83.             if(TV_new != NULL)    {
  84.                 //    Insert onto the desktop.
  85.                 deskTop->insert(TV_new);
  86.                 //    Here we insert the url into the open
  87.                 //    url history list.
  88.                 historyAdd(usi_OpenURLHist, cp_argument);
  89.                 //    Don't load home if URL on command
  90.                 //    line.
  91.                 B_loadHome = False;
  92.             }
  93.         }
  94.         else    {
  95.             //    Move argument past the '/'
  96.             cp_argument++;
  97.  
  98.             if(*cp_argument == '?')    {
  99.                 //    Command line help for switches
  100.                 doslynxmessage("Command line help not yet "
  101.                     "implemented.");
  102. #ifdef TODO
  103. #error Implement command line help.
  104. #endif    //    TODO
  105.             }
  106.             else if(toupper(*cp_argument) == 'P')    {
  107.                 //    This will set the path of the ini file
  108.                 cp_argument++;
  109.  
  110.                 //    Free if previously encountered.
  111.                 if(cp_inipath != NULL)    {
  112.                     delete(cp_inipath);
  113.                 }
  114.  
  115.                 //    Construct the global path variable.
  116.                 cp_inipath = new char[strlen(cp_argument) +
  117.                     1];
  118.                 strcpy(cp_inipath, cp_argument);
  119. #ifndef RELEASE
  120.                 trace("Configuration files in " <<
  121.                     cp_inipath);
  122. #endif // RELEASE
  123.             }
  124.             else if(toupper(*cp_argument) == 'T')    {
  125.                 //    This will set the temporary directory
  126.                 //    in which to write temporary files.
  127.                 cp_argument++;
  128.  
  129.                 if(cp_TempDir != NULL)    {
  130.                     delete(cp_TempDir);
  131.                 }
  132.  
  133.                 //    Construct the global temp dir name.
  134.                 cp_TempDir = new char[strlen(cp_argument) +
  135.                     1];
  136.                 strcpy(cp_TempDir, cp_argument);
  137. #ifndef RELEASE
  138.                 trace("Temporary file directory is " <<
  139.                     cp_TempDir);
  140. #endif // RELEASE
  141.             }
  142.             else if(toupper(*cp_argument) == 'L')    {
  143.                 //    This will set the maximum number of
  144.                 //    loaded HTexts.
  145.                 cp_argument++;
  146.  
  147.                 //    Make sure that we can covert the
  148.                 //    string, if unable, keep the default
  149.                 //    maximum.
  150.                 usi_MaxLoadedHTexts = atoi(cp_argument) == 0
  151.                     ? usi_MaxLoadedHTexts : atoi(
  152.                     cp_argument);
  153. #ifndef RELEASE
  154.                 trace("Maximum loaded HTexts set to " <<
  155.                     usi_MaxLoadedHTexts);
  156. #endif // RELEASE
  157.             }
  158. #ifndef RELEASE
  159.             else if(strcmpi(cp_argument, "debug") == 0)    {
  160.                 //    Enable debugging mode.
  161.                 c_trace = 1;
  162.                 trace("Debug mode enabled at argument " <<
  163.                     i_sequence);
  164.             }
  165. #endif // RELEASE
  166.             else if(toupper(*cp_argument) == 'V')    {
  167.                 //    This will set what text mode the
  168.                 //    user hopes to set to.
  169.                 cp_argument++;
  170.  
  171.                 //    Check for high or low.
  172.                 if(stricmp("HIGH", cp_argument))    {
  173.                 if(stricmp("LOW", cp_argument))    {
  174.                     //    bad value.
  175.                 }
  176.                 else    {
  177.                     //    low
  178.                     if(B_isLow != True)    {
  179.                         switchVideo();
  180.                     }
  181.                 }
  182.                 }
  183.                 else    {
  184.                     //    high
  185.                     if(B_isLow != False)    {
  186.                         switchVideo();
  187.                     }
  188.                 }
  189.             }
  190.             else if(toupper(*cp_argument) == 'H')    {
  191.                 //    This will set wether or now DosLynx
  192.                 //    will load up the home page once
  193.                 //    started.
  194.                 cp_argument++;
  195.  
  196.                 //    Check for on or off.
  197.                 if(stricmp("OFF", cp_argument))    {
  198.                 if(stricmp("ON", cp_argument))    {
  199.                     //    bad value.
  200.                 }
  201.                 else    {
  202.                     //    on
  203.                     B_loadHome = True;
  204.                 }
  205.                 }
  206.                 else    {
  207.                     //    off
  208.                     B_loadHome = False;
  209.                 }
  210.             }
  211.             else if(toupper(*cp_argument) == 'N')    {
  212.                 //    This will set wether or not DosLynx
  213.                 //    will allow network access
  214.                 cp_argument++;
  215.  
  216.                 //    Check for yes or no.
  217.                 if(stricmp("YES", cp_argument))    {
  218.                 if(stricmp("NO", cp_argument))    {
  219.                     //    bad value.
  220.                 }
  221.                 else    {
  222.                     //    no
  223.                     i_networked = 0;
  224.                 }
  225.                 }
  226.                 else    {
  227.                     //    yes
  228.                     i_networked = 1;
  229.                 }
  230.             }
  231.             else    {
  232.                 //    Print an error if argument not found.
  233.                 doslynxmessage("Unknown command line option "
  234.                     << (cp_argument - 1));
  235.             }
  236.         }
  237.     }
  238. }
  239.